<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>4.类型转换</title>
</head>

<body>
  <!-- 1.发生类型转换的情况 -->
  1. 字符串拼接
  2. ==
  3. if语句和逻辑运算
  <script>
    // 1.字符串拼接
    const a = 100 + 10
    const b = 100 + '10'
    const c = true + '10'
    console.log(a); // 110
    console.log(b); //10010
    console.log(c); // true10

    // 2.==
    console.log(100 == '100'); // true
    console.log(0 == ''); // true
    console.log(0 == false); // true
    console.log(false == ''); // true
    console.log(null == undefined); // true

    // !!出了== null 之外 其他一律用===
    const obj = { x: 100}
    if (obj.a == null) {} // 相当于 if (obj.a === null || obj.a === undefined)

    // 3.if语句和逻辑运算 本质上是考虑truely变量和falsely变量
    // truely变量: !!a === true
    // falsely变量: !!a === false

    // 0 Nan '' null undefined false是falsely对象 
    // 其余都是truely对象





  </script>
</body>

</html>